import datetime
import pytz

import coin.exchange.base.kr_rest.native_public_client_base as npubcb

class BitbankNativePublicClient(npubcb.NativePublicClientBase):
  def __init__(self):
    npubcb.NativePublicClientBase.__init__(self, url="https://public.bitbank.cc")
    self._valid_kline_period = ['1min', '5min', '15min', '30min', '1hour', \
        '4hour', '8hour', '12hour', '1day', '1week', '1month']

  def check_kline_period(self, kline_period):
    assert kline_period in self._valid_kline_period, \
      'Invalid kline period! %s' % kline_period

  def get_history_kline(self, symbol, kline_period, start_time, end_time=None):
    self.check_kline_period(kline_period)

    return self._get_as_json("%s/candlestick/%s/%s" % (symbol, kline_period, start_time))

  def queryAll(self):
    raise NotImplementedError()


if __name__ == "__main__":
  client = BitbankNativePublicClient()
  print(client.get_history_kline('btc_jpy', '1hour', '20201105').msg)
